package com.psd.demo.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.pds.demo.dao.OrganizationDao;
import com.pds.demo.dao.impl.OrganizationDaoImpl;
import com.pds.mvc.ActionForward;
import com.pds.mvc.Actions;
import com.psd.demo.model.User;

public class UpdateEmpServlet extends Actions {

	@Override
	public ActionForward execute(HttpServletRequest request,
			HttpServletResponse response) {
		String sid = request.getParameter("userid");
		int id = Integer.parseInt(sid);

		// 获取到提交的username
		String username = request.getParameter("username");
		String password = request.getParameter("userpass");
		String realname = request.getParameter("realname");
		//int sex = Integer.parseInt(request.getParameter("usersex"));

		int age = Integer.parseInt(request.getParameter("userage"));

		String sql = "update USER set USER_NAME=?,USER_PASS=?,"
				+ "REAL_NAME=?,USER_AGE=?,USER_SEX=? "
				+ "where USER_ID=?";
		OrganizationDao dao = new OrganizationDaoImpl();
		try {
			User user = new User();
			user.setUserName(username);
			user.setUserPass(password);
			user.setRealName(realname);
			user.setUserAge(age);
	//		user.setUserSex(sex);
			user.setUserId(id);
			dao.update(sql, user);
		} catch (Exception e) {

		}
		return new ActionForward("emplist.action", true);

	}

}
